package com.demo.client;

import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.provider.IQProvider;
import org.xmlpull.v1.XmlPullParser;

/**
 * this class parse IQ packet to NotificationProvider
 * 
 * @author Administrator
 *
 */
public class NotificationIQProvider implements IQProvider{

	public NotificationIQProvider()
	{
		
	}
	@Override
	public IQ parseIQ(XmlPullParser parser) throws Exception {
		
		NotificationIQ notification = new NotificationIQ();
		
		for(boolean done = false;!done;)
		{
			int eventType = parser.next();
			if(eventType == 2)
			{
				if("id".equals(parser.getName()))
				{
					notification.setId(parser.nextText());
				}
				if("apiKey".equals(parser.getName()))
				{
					notification.setApiKey(parser.nextText());
				}
				if("title".equals(parser.getName()))
				{
					notification.setTitle(parser.nextText());
				}
				if("message".equals(parser.getName()))
				{
					notification.setMessage(parser.nextText());
				}
				if("uri".equals(parser.getName()))
				{
					notification.setUri(parser.nextText());
				}
			}
		}
		return notification;
	}

}
